package com.xyb.controller;

import com.xyb.service.RegisterService;
import com.xyb.utils.CheckUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/register")
public class RegisterController {

    @Resource
    private RegisterService registerService;

    @PostMapping("/code/{iphoneNo}")
    public boolean insertRegisterCodeByIphoneNo(@PathVariable("iphoneNo") String iphoneNo){
        //校验手机号
        boolean b = CheckUtils.checkIphoneNo(iphoneNo);
        //业务处理
        boolean flag = registerService.sendRegCode(iphoneNo);
        return flag;
    }

    @GetMapping("/code/{iphoneNo}/{code}")
    public boolean selectRegisterCodeByIphoneNo(@PathVariable("iphoneNo") String iphoneNo,@PathVariable("code") Integer code){
        boolean flag = registerService.selectRegisterCodeByIphoneNo(iphoneNo,code);
        return flag;
    }
}